package logic

import (
	"context"
	"video-hub/videorpc/videorpc"

	"video-hub/api/internal/svc"
	"video-hub/api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type SendSmsLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewSendSmsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SendSmsLogic {
	return &SendSmsLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *SendSmsLogic) SendSms(req *types.SendSmsRequest) (resp *types.Response, err error) {
	// todo: add your logic here and delete this line

	add, err := l.svcCtx.VideoRpc.SendSms(l.ctx, &videorpc.SendSmsRequest{
		PhoneNum: req.PhoneNum,
	})
	if err != nil {
		return &types.Response{
			Message: "获取短信验证码失败",
			Code:    500,
			Data:    nil,
		}, nil
	}
	return &types.Response{
		Message: "获取短信验证码成功",
		Code:    200,
		Data:    add,
	}, nil
}
